<template>
  <div>
    <vue-office-pdf
      style="height: 800px"
      :src="src"
      @rendered="renderedHandler"
      @error="errorHandler"
    />
    <span class="loading-text" v-if="loding">正在加载中...请等待</span>
  </div>
</template>

<script>
//引入VueOfficePdf组件
import VueOfficePdf from '@vue-office/pdf';
export default {
  name: 'VueOfficePdfDemo',
  components: {
    VueOfficePdf,
  },
  data() {
    return {
      loding: true,
      pdf: 'http://static.shanhuxueyuan.com/test.pdf', //设置文档地址
    };
  },
  props: {
    src: {
      type: String,
      default: '',
    },
  },
  methods: {
    renderedHandler() {
      console.log('渲染完成');
      this.loding = false;
    },
    errorHandler() {
      console.log('渲染失败');
    },
  },
};
</script>

<style scoped>
.loading-text {
  display: block;
  line-height: 200px;
  text-align: center;
  background: #808080;
  color: #fff;
  font-size: 20px;
}
</style>
